package J5_2;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class test {
    public String formatString (String str, char[] arg) {
        StringBuilder ret = new StringBuilder();
        int pos = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '%') {
                ret.append(arg[pos++]);
                i++;
            } else {
                ret.append(str.charAt(i));
            }
        }
        while (pos < arg.length) {
            ret.append(arg[pos++]);
        }
        return new String(ret);
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt();
        int ret = 0;
        for (int i = Math.max(a, 10); i <= b; i++) {
            ret += check(i);
        }
        System.out.println(ret);
    }

    private static int check(int i) {
        int[] arr = new int[10];
        int len = 0;
        while (i > 0) {
            arr[len++] = i % 10;
            i /= 10;
        }
        for (int j = 0; j < len - 1; j++) {
            for (int k = j + 1; k < len; k++) {
                if (arr[j] == 0 ||arr[k]==0) {
                    continue;
                }
                if (isPrime(arr[j] * 10 + arr[k]) || isPrime(arr[j] + arr[k] * 10)) {
                    return 1;
                }
            }
        }
        return 0;
    }

    private static boolean isPrime(int i) {
        if (i < 2) {
            return false;
        }
        for (int j = 2; j <= Math.sqrt(i); j++) {
            if (i % j == 0) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int x = in.nextInt();
        int len = str.length();
        if (len == 1) {
            System.out.println(str);
            return;
        }
        int l = 0, r = 0, count = 0, max = 0, maxL = 0, maxR = 0, pos = 0, maxCount = 0;
        char[] ch = str.toCharArray();
        while (r < len && r - l < x) {
            if (ch[r] == 'C' || ch[r] == 'G') {
                count++;
            }
            r++;
        }
        maxCount = count;
        maxL = l;
        maxR = r;
        while (r < len) {
            if (ch[r] == 'C' || ch[r] == 'G') {
                count++;
            }
            r++;
            if (ch[l] == 'C' || ch[l] == 'G') {
                count--;
            }
            l++;
            if (count > maxCount) {
                maxCount = count;
                maxL = l;
                maxR = r;
            }
        }
        System.out.println(str.substring(maxL,maxR));

    }
}
